package weixin02.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import weixin02.entity.Advertisement;
import weixin02.entity.GoodsType;
import weixin02.service.AdvertisementService;
import org.springframework.web.bind.annotation.*;
import weixin02.util.R;

import javax.annotation.Resource;

/**
 * (Advertisement)表控制层
 * @author makejava
 * @since 2021-07-06 21:14:22
 */
@Api(tags = "轮播图接口")
@RestController
@RequestMapping("advertisement")
public class AdvertisementController {

    @Resource
    private AdvertisementService advertisementService;

    /*查询所有轮播图*/
    @ApiOperation(value = "查询所有轮播图",notes = "查询所有轮播图")
    @GetMapping("queryAllAd")
    public R queryAllAd(){
        return advertisementService.queryAll();
    }

    /*根据id查询轮播图*/
    @ApiOperation(value = "根据id查询轮播图",notes = "根据id查询轮播图")
    @GetMapping("queryAdById")
    public R queryAdById(int id){
        return advertisementService.queryById(id);
    }

    /*增加轮播图*/
    @ApiOperation(value = "增加轮播图",notes = "增加轮播图")
    @GetMapping("addAd")
    public R addAd(Advertisement advertisement){
        return advertisementService.insert(advertisement);
    }

    /*更新轮播图*/
    @ApiOperation(value = "更新轮播图信息",notes = "更新轮播图")
    @GetMapping("updateAd")
    public R updateAd(Advertisement advertisement){
        return advertisementService.update(advertisement);
    }

    /*删除轮播图*/
    @ApiOperation(value = "删除轮播图",notes = "删除轮播图")
    @GetMapping("deleteAd")
    public R deleteAd(int id){
        return advertisementService.deleteById(id);
    }

}
